const baseURL = 'http://nocat.life:3012';

const request = async (url,method,data,isloading = true) =>{
	//显示加载动画
	// if(isloading){
	// 	uni.showLoading({
	// 		title:'加载中'
	// 	})
	// }
	
	const res = await uni.request({
		url:baseURL + url,
		method,
		data,
		timeout:3000,
		header:{
			Authorization:uni.getStorageSync('user_token')
		}
	});
	//加载动画隐藏
	uni.hideLoading();
	
	return res.data
}

export const httpGet = (url, data, isLoading) => {
	return request(url, 'GET', data, isLoading);
}
export const httpPost = (url, data, isLoading) => {
	return request(url, 'POST', data, isLoading);
}
export const httpDelete = (url, data, isLoading) => {
	return request(url, 'DELETE', data, isLoading);
}
export const httpPut = (url, data, isLoading) => {
	return request(url, 'PUT', data, isLoading);
}